<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	
	<link rel="stylesheet" type="text/css" href="../../css/base.css" />
	<link id="easyuiTheme"  rel="stylesheet" type="text/css" href="../../easy-ui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../easy-ui/themes/icon.css">
	<script type="text/javascript" src="../../easy-ui/jquery.min.js"></script>	
	<script type="text/javascript" src="../../easy-ui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../easy-ui/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../js/base.js" ></script>
	<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=BxytRxhw8nBC4IKKKOkh8p1Q"></script>
	  
    <style type="text/css">
    body,html,div,ul,li,span,p,input,form,label,a,img,em,dl,dt,dd,textarea,h3,table,th,td,tr{margin:0;padding:0;font-size:12px;font-family:"'微软雅黑 ', '微软雅黑'"!important;list-style:none;font-style:normal;word-break: break-all;word-wrap: break-word;}
	input[type="text"]::-ms-clear{display:none;}
	input[type="radio"],input[type="checkbox"]{cursor:pointer;vertical-align:middle;}
	.fl{float:left;}
	.fr{float:right;}
	.oh{overflow:hidden;}
	.table-gray{background: #f8f8f8;text-align: right;line-height: 20px;}
	.myTable{ padding: 30px; border: 1px solid #c9c9c9;}
	.td-span{padding-left: 15px;}
	.myTable>table{width: 100%; border-top: 1px solid #c9c9c9; border-right: 1px solid #c9c9c9;}
	.myTable>table>tbody>tr{overflow: hidden;}
	.myTable>table>tbody>tr>td{border-left: 1px solid #c9c9c9;border-bottom: 1px solid #c9c9c9;padding:10px;}
	.myTable>table>tbody>tr>td>input{height: 24px;width: 80px;}
	.myTable>table>tbody>tr>td>select{width: 100%;}
	.myTable>table>tbody>tr>td>textarea{width: 100%;}
	.td-sec{margin: 8px 8px;}
	.td-sec>span{padding-right: 8px;}
	.td-sec>span>input{width: 60px;}
	.td-a{display: block;background: #0d73b4;width: 75px;height: 24px;line-height: 24px;text-align: center;
	border-radius: 5px;-moz-border-radius: 5px;-ms-border-radius: 5px;-webkit-border-radius: 5px;-o-border-radius:5px;
	color: #fff}
	.td-third>textarea{width: 85%; height: 80px;margin-left: 8px;}
	.table-solo{overflow: hidden;text-align: center;}
	.table-solo>td{border: 1px solid #C9C9C9;padding: 5px;}
	    
    
    </style>
</head>


<body class="easyui-layout" data-options="fit:true" style="overflow:hidden;">
		
		<div data-options="region:'south',border:false," style="height:45px;text-align:center;">
		
			<table style="width:100%;margin-top:8px;" >
				<tr><td style="align:center;">
				<a href='javascript:void(-1);' onclick="baseFormSubmit();"; class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a>&nbsp;&nbsp;
				<a href='javascript:void(-1);' onclick="baseFormReset();";  class="easyui-linkbutton" data-options="iconCls:'icon-back'">重置</a>
				</td></tr>
			</table>
		</div>
		
		<div data-options="region:'center',border:true,">
		
		<!-- the dataForm start  -->
		<form id="baseForm" name="baseForm" method="post" target="hiddenFrame" style="margin:0px;padding:0px;overflow:hidden;">
		<input id="id" name="id" type="hidden" /> 
		<input id="type" name="type" type="hidden" value="3" /> 
		<input id="province" name="province" type="hidden" />
		<input id="city" name="city" type="hidden" /> 
		<input id="area" name="area" type="hidden" /> 
		<input id="thirdCinemaId" name="thirdCinemaId" type="hidden" /> 
		<div class="myTable">
				  <table cellpadding="0" cellspacing="0">
				    <tbody>
				      <tr>
				        <td class="table-gray" width="10%" >主店名：</td>
				        <td colspan="3">
 			       		 <input  name="name" id="name"  type="text"  type="text" style="width: 50%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true" >
 			       		 <a href='javascript:void(-1);' onclick="searchName();";  class="easyui-linkbutton" data-options="iconCls:'icon-back'">搜索</a>			        
				        
				      </tr>
				      <tr>
				        <td class="table-gray" width="10%" >分店名：</td>
				        <td colspan="1">
				        <input  name="subName" id="subName"  type="text" style="width: 100%;" class="easyui-validatebox textbox" >
				        </td>
				        <td class="table-gray" width="10%" >简称：</td>
				        <td colspan="1">
				        <input  name="shortName" id="shortName"  type="text" style="width: 100%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true">
				        </td>
				      </tr>
				      <tr>
				      </tr>
				      <tr>
				        <td class="table-gray" width="10%" >前置服务器：</td>
				        <td colspan="1">
				        <input  name="preServerUrl" id="preServerUrl"  type="text" style="width: 100%;" class="easyui-validatebox textbox" >
				        </td>
				        <td class="table-gray" width="10%" >第三方停车场：</td>
				        <td colspan="1">
				        <input  name="thirdPark" id="thirdPark"  type="text" style="width: 100%;" class="easyui-validatebox textbox" >
				        </td>
				      </tr>
				      <tr>
				      <td class="table-gray" width="10%" >第三方电影院：</td>
				        
				        <td colspan="3" class="data-table-input">
							<input class="easyui-combobox" id="thirdCinemaId_combobox" 
									data-options="valueField:'id',textField:'text',editable:true," style="width:202px;"/>	
						</td>
				      </tr>
				    <!--  <tr>
				        <td class="table-gray" width="10%" >搜索地址：</td>
				        <td colspan="3">
				       		 <input  id="searchName"  type="text" style="width: 50%;" class="easyui-validatebox textbox" >
				       		 
				        </td>
				      </tr>  -->
				      
				        <tr>
				        <td class="table-gray">选择经纬度：</td>
				        <td colspan="3">
				         	<div style="width:100%;height:400px;" id="map"> 
				         	</div>
				        </td>
				      </tr>
				       
				      <tr>
				         <td class="table-gray">详细地址:</td>
				        <td colspan="3">
				        	<input  name="address" id="address"  type="text" style="width: 100%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true" >
				        </td>
				      </tr>
				      <tr>
				         <td class="table-gray">经度:</td>
				        <td >
				        	<input  name="lon" id="lon"  type="text" style="width: 100%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true" >
				        </td>
				         <td class="table-gray">纬度:</td>
				        <td >
				        	<input  name="lat" id="lat"  type="text" style="width: 100%;" class="easyui-validatebox textbox" data-options="required:true,novalidate:true" >
				        </td>
				      </tr>
				      
				    
				    </tbody>
				  </table>
				</div>
			</form>
		<!-- the dataForm end  -->


		</div>
	
	

	<script type="text/javascript">
		var localSearch,map;
		function initPage(){
			parent.showProgressing();
			sendRequestAjax('../../zcshop/initAddStore.do?responseFunction=initAdd',initAdd);
		}
		window.onload=function(){
			initPage();
		}

		var responseResultPage;
		function initAdd(responseResult){
			setFormDefault(responseResult); 
			responseResultPage=responseResult;
			 $('#thirdCinemaId_combobox').combobox({
		  		data: responseResult.cinemas,
		  		value:"",
		  		mode:"local",
		  		//width:parseInt($("#baseForm")[0].offsetWidth)+2,
		  		onSelect: function(record){
			  			document.getElementById("thirdCinemaId").value=record.id;
			  			//document.getElementById("searchSexShow").value=record.text;
				},
				filter: function(q, row){
					var opts = $(this).combobox('options');
					var is = row[opts.textField].indexOf(q) >= 0;
					return is;
				}
				
			}); 
			parent.closeProgressing();  
			
			map = new BMap.Map("map",{enableMapClick:false,
				minZoom : 11,
				maxZoom : 19
			});
			var point = new BMap.Point(114.05, 22.6);
			var geoc = new BMap.Geocoder();
			var zoom = 13;
			//map.centerAndZoom(point, zoom);
			map.centerAndZoom("深圳", zoom);
			map.enableScrollWheelZoom(true);// 鼠标滑动轮子可以滚动
			map.addControl(new BMap.ScaleControl({
				anchor : BMAP_ANCHOR_BOTTOM_RIGHT
			})); // 添加比例尺控件
			
			localSearch = new BMap.LocalSearch(map, {
				renderOptions:{map: map}
			});
		    localSearch.enableAutoViewport(); //允许自动调节窗体大小
			function showInfo(e){
				//alert(e.point.lng + ", " + e.point.lat);
				map.clearOverlays(); 
				var pt = e.point;
				$("#lat").val(pt.lat);
				$("#lon").val(pt.lng);
				
				geoc.getLocation(pt, function(rs){
					var addComp = rs.addressComponents;
					//alert(addComp.province + ", " + addComp.city + ", " + addComp.district + ", " + addComp.street + ", " + addComp.streetNumber);
					$("#address").val(addComp.province+addComp.city+ addComp.district + addComp.street + addComp.streetNumber);
					$("#province").val(addComp.province);
					$("#city").val(addComp.city);
					$("#area").val(addComp.district);
					//console.log(addComp);
				});  
				
				point = new BMap.Point(e.point.lng, e.point.lat);
				var marker = new BMap.Marker(point);  // 创建标注
				map.addOverlay(marker);               // 将标注添加到地图中
				marker.setAnimation(BMAP_ANIMATION_BOUNCE); //跳动的动画
			}
			map.addEventListener("click", showInfo);
			
			map.addControl(new BMap.CityListControl({
			    anchor: BMAP_ANCHOR_TOP_LEFT,
			    offset: zoom,
			    // 切换城市之间事件
			    // onChangeBefore: function(){
			    //    alert('before');
			    // },
			    // 切换城市之后事件
			    // onChangeAfter:function(){
			    //   alert('after');
			    // }
			}));
		}
		
		    
		function searchName(){
			var name = $("#name").val();
			if(name !=null && name !=''){
				 map.clearOverlays();//清空原来的标注
				 
				
			    localSearch.search(name);
				    
			}
		}
	
	
	
	
	
		//form表单 提交 重置 提交后响应处理 ----------------
		function baseFormSubmit(){
			
			var flag= $("#baseForm").form('enableValidation').form('validate');
		    if(flag){
		    	
		    	parent.showProgressing();
				sendRequestAjax('../../zcshop/addSaveBase.do?responseFunction=addSave',addSave);
		    }
			
		}
		
		function baseFormReset(){
			
			 initAdd(responseResultPage);  
			
		}
		
		function addSave(responseResult){
			
		    executeWindowCallback( {});
			
			if(responseResult.slide_msg_key==1){
				parent.parent.showSlideMsg(responseResult.slide_msg_message_key);
			}
			parent.closeProgressing();
			
			//关闭当前tab
 			var currentTab =parent.parent.$('#tabs').tabs('getSelected');
            var currtab_title = currentTab.panel('options').title;
            var currtab_id = currentTab.panel('options').id;
            if(currtab_id!='index_welcome_id'){
           		 parent.parent.$('#tabs').tabs('close', currtab_title);
            }
		}
		
		
	</script>
</body>
</html>